home *** CD-ROM | disk | FTP | other *** search
/ Internet Tools (InfoMagic) / Internet Tools.iso / dos_win / winsock / hacklist / 94-04.Z / 94-04 / 000013_paul@atlas.dev.abccomp.oz.au_Mon Apr 11 05:28:52 1994.msg < prev    next >
Internet Message Format  |  1994-04-30  |  28KB

  1. Received: from usage.csd.unsw.OZ.AU by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  2.           id AA13912; Sun, 10 Apr 1994 20:16:05 -0400
  3. Received: by usage.csd.unsw.OZ.AU id AA22107
  4.   (5.65c/IDA-1.4.4 for winsock-hackers%sunsite.unc.edu); Mon, 11 Apr 1994 10:15:46 +1000
  5. Received: by atlas (4.1/1.35)
  6.     id AA01926; Mon, 11 Apr 94 10:28:53 EST
  7. Message-Id: <9404110028.AA01926@atlas>
  8. From: paul@atlas.abccomp.oz.au
  9. Date: Mon, 11 Apr 1994 10:28:52 -0500
  10. X-Mailer: Mail User's Shell (7.2.2 4/12/91)
  11. To: stcheng@ee.tamu.edu,
  12.         Multiple recipients of list <winsock-hackers@sunsite.unc.edu>
  13. Subject: Re: setoptsock()
  14.  
  15. Thus expounded Franklin S. Cheng on Apr 8,11:19pm:
  16. /--------------------
  17. |
  18. |Fellow hackers,
  19. |
  20. |setoptsock() allows socket programmers to modify the socket
  21. |options, like the buffer size for sending and receiving.(using 
  22. |level= SOL_SOCKET and optname= SO_RCVBUF and SO_SNDBUF)
  23. |
  24. |My question is when the  _receiving_  buffer size is bigger than one UDP packet,
  25. |say 5 times. Will the incoming 5 packets be held in the buffer if
  26. |the app doesn't read it ? Or no matter how big the buffer size is,
  27. |it always holds just one UDP packet and discard the subsequence UDP
  28. |packets if the apps doesn't read it ? What about if the buffer size
  29. |is 5.3 times of the size of the incoming UDP packets , would the 
  30. |6th one be stuffed into the remaining buffer size -- .3 of the UDP
  31. |packet ?
  32.  
  33. Most of this is implementation dependent - UDP is _not_ a reliable
  34. protocol, and datagrams can be lost at any stage - even once they have
  35. safely negotiated the cables and are inside the machine!
  36.  
  37. On the other hand, an implementation that prevented th euser from
  38. receiving all the packets possible would be seriously deficent.
  39.  
  40. All I can describe is our implementation, which (naturally) I believe
  41. to be the only sensible method :)
  42.  
  43. Multiple incoming UDP packets are queued, unless the new packet would take
  44. the total aggregate buffer size over the receive buffer limit - i.e. 
  45. in your example above, if the receive buffer was 5.3 times larger than
  46. the incoming packets, the first 5 would be queued, the sixth and subsequent
  47. packets would be dropped until some of the successful packets have been read.
  48.  
  49. On the other hand, we don't implement changing the UDP receive buffer at
  50. all, so calling setsockopt(SO_RCVBUF) ona UDP socket doesn't acheive
  51. a great deal! (its conceptually 4K fixed presently). This may be implemented
  52. soon.
  53.  
  54. |And how about the _sending_ buffer for this case ?
  55.  
  56. Actually, I don't believe the concept of a sending buffer is applicable for
  57. a UDP socket - each send() by the application results in a separate
  58. datagram, which can be sent immediately to the output interface. If you
  59. send too many too fast for the interface, they get dropped from the output
  60. interface queue, which is totally unrelated to any socket.
  61. |
  62. |thanks,
  63.  
  64. Anytime.
  65.  
  66. |
  67. |Franklin.
  68.  
  69. Cheers,
  70.  
  71.  
  72. -- 
  73. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard:
  74. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet
  75. 579 Harris St., Ultimo   |                         |  been superseded.
  76. Sydney Australia 2007    |ph: +61 2 281 3155       |  
  77. From paul@atlas.dev.abccomp.oz.au Mon Apr 11 06:01:34 1994
  78. Received: from usage.csd.unsw.OZ.AU by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  79.           id AA18479; Sun, 10 Apr 1994 20:49:09 -0400
  80. Received: by usage.csd.unsw.OZ.AU id AA23690
  81.   (5.65c/IDA-1.4.4 for winsock-hackers%sunsite.unc.edu); Mon, 11 Apr 1994 10:48:30 +1000
  82. Received: by atlas (4.1/1.35)
  83.     id AA02023; Mon, 11 Apr 94 11:01:36 EST
  84. Message-Id: <9404110101.AA02023@atlas>
  85. From: paul@atlas.abccomp.oz.au
  86. Date: Mon, 11 Apr 1994 11:01:34 -0500
  87. X-Mailer: Mail User's Shell (7.2.2 4/12/91)
  88. To: bryan@alex.com,
  89.         Multiple recipients of list <winsock-hackers@sunsite.unc.edu>
  90. Subject: Re: Closing and reusing sockets
  91.  
  92. Thus expounded Bryan Boreham on Apr 8,11:40pm:
  93. /--------------------
  94. |>From Paul Brooks, paul@abccomp.oz.au:
  95. |
  96. |>True, but you still have to think about the case where your local machine
  97. |>has closed the socket down OK, allowing you to BIND to the same
  98. |>port number in the future, but the REMOTE end still has the same
  99. |>port/address association valid, probably in TIMEWAIT state for two minutes.
  100. |>
  101. |>In this case, your bind() will succeed, but the remote end may well refuse
  102. |>the connection. WSAEADDRINUSE is a valid return from connect(),
  103. |
  104. |Aha!  I was working on the assumption that EADDRINUSE referred to the
  105. |*local* address, not the remote address.  The spec doesn't specify --
  106. |is there any other explicit reference?  I see that Stevens "Unix Network 
  107. |Programming" does use it as you describe in the rcmd example, page 570.
  108.  
  109. I wasn't aware of the passage, I was remembering some bad experiences I have
  110. had, making unwarranted assumptions that just because one end has forgotten
  111. about a previous connection, the other end has too.
  112.  
  113. When you look at the sequence of closing a socket - the FIN, FIN/ACK, ACK
  114. exchange - its the end that initiates the first FIN that ends up in the
  115. two minute long TIME-WAIT state, while the other end can forget the
  116. connection completely. For client/server things, usually its the
  117. server end that ends up doing this, in response to a signal from the client
  118. (i.e. Telnet, where the server closes the connection after the user
  119. types 'logout' or '^D', or FTP data connections, where the end thats sending
  120. does the close).
  121.     In this case, the local end can successfully bind() to a previously
  122. used local port, and connect() to a previously used remote port.
  123. When the SYN gets to the remote end, however, it may find a matching
  124. socket in TIME-WAIT, and the remote end may refuse the connection.
  125.  
  126. |However, exactly the same circumstances didn't result in a failure at all
  127. |using the Trumpet stack.  I think I'll do some network sniffing to see if
  128. |I can spot what is different.
  129.  
  130. Just because this is a possible (and probable) connection failure mechanism,
  131. I'm still not sure how the local end would distinguish this case and return
  132. WSAEADDRINUSE for the connect() return, instead of the more usual
  133. WSAECONNREFUSED. Possibly if the remote end returned a FIN, believing the
  134. new SYN to be an artifact of the previous connection.
  135. |
  136. |Here is one specifc case: suppose a program uses rsh twice in 
  137. |succession, something which is very easy in the Alex language.  We must 
  138. |bind to a free reserved port locally, and we must connect to the same 
  139. |remote port each time.  We would like to do this reliably on any of
  140. |the dozen or more Winsock stacks that our customers might use, with
  141. |the minimum of hack work-arounds that "just happen to fix it".
  142.  
  143. Use the two-tiered loop around connect() and bind() - don't assume that
  144. just because you can bind() to a local port, that the following connect()
  145. will succeed. This should work, even with potentially broken stacks that
  146. can't check sockets at bind() time properly.
  147.  
  148.  
  149. -- 
  150. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard:
  151. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet
  152. 579 Harris St., Ultimo   |                         |  been superseded.
  153. Sydney Australia 2007    |ph: +61 2 281 3155       |  
  154. From paul@atlas.dev.abccomp.oz.au Mon Apr 11 09:52:24 1994
  155. Received: from usage.csd.unsw.OZ.AU by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  156.           id AA19791; Mon, 11 Apr 1994 00:39:11 -0400
  157. Received: by usage.csd.unsw.OZ.AU id AA04534
  158.   (5.65c/IDA-1.4.4 for winsock-hackers%sunsite.unc.edu); Mon, 11 Apr 1994 14:39:22 +1000
  159. Received: by atlas (4.1/1.35)
  160.     id AA03112; Mon, 11 Apr 94 14:52:24 EST
  161. Message-Id: <9404110452.AA03112@atlas>
  162. From: paul@atlas.abccomp.oz.au
  163. Date: Mon, 11 Apr 1994 14:52:24 -0500
  164. X-Mailer: Mail User's Shell (7.2.2 4/12/91)
  165. To: winsock-hackers@sunsite.unc.edu, davidtr@microsoft.com
  166. Subject: Windows Sockets 1.1 errata list.
  167.  
  168. This is a list of typos and minor irritants I have found in the
  169. WinSock 1.1 spec. I'm listing them here since it is likely to me that the
  170. 2.0 spec. will borrow much of the text of the 1.1 document, and I
  171. would like to see them cleared out for the 2.0 document.
  172.  
  173. I'm also listing some minor issues that need clarifying text within the
  174. 1.1 spec, in the hope that they will be included in the 2.0 document, and
  175. possibly also in a '1.1 addendum' document.
  176.  
  177. I won't be able to attend the V2.0 discussions at Winsockathon, but would
  178. like these issues tabled for discussion there.
  179.  
  180. Typos etc.
  181. ----------
  182. Page 25:        Superfluous 'r' character just above '4.1.4 connect()
  183.                 should be removed.
  184.  
  185. Page 26:        WSAEINVAL is not a possible error code for connect(), and
  186.                 it should be removed. Connect() will perform an automatic
  187.                 internal bind() if required, as already described in the
  188.                 Remarks section.
  189.  
  190. Page 27:        Add text to WSAEFAULT error explanation:
  191.                 ..., or one or both of name and namelen are not valid
  192.                 pointers.
  193.  
  194. Page 29:        The type of optname (int) clashes with the declared type
  195.                 of the SO_DONTLINGER socket option in WINSOCK.H (u-int).
  196.                 Suggest changing WINSOCK.H to make SO_DONTLINGER a signed
  197.                 integer to accomodate developers using strict environments.
  198.                 e.g.     #define SO_DONTLINGER (int)(~SO_LINGER).
  199.  
  200. Page 36:    Add 'WSAEFAULT    argp is not a valid pointer' to Error Codes
  201.         section.
  202.  
  203. Page 42;    Add 'WSAEFAULT  buf is not a valid pointer' to error codes
  204.         section.
  205.  
  206. Page 43:    second-last paragraph in Remarks section, bottom of page:
  207.         "If the connection has been reset recv() will fail..." -
  208.         recv() should be recvfrom().
  209.  
  210. Page 44:    The WSAEFAULT explanation should begin "The from and/or
  211.         fromlen argument(s) was invalid"
  212.  
  213. Page 47:    Add "WSEFAULT    one of the argument pointers was invalid"
  214.         to Error Codes Section.
  215.  
  216. Page 55:    In setsockopt, in the table at top of P55, the line for
  217.         SO_ERROR should be removed, its a hangover from a block copy
  218.         from getsockopt().
  219.  
  220. Page 60:    Halfway down in the explanation of the members of the
  221.         hostent structure, the "(PC)" should be removed from 
  222.         the h_name entry - theres nothing specific in a hostent
  223.         entry for a PC, and the return from gethostbyYYY need not
  224.         be a PC.
  225.  
  226. Page 62:    The title at the top of the page containing '4.2.2
  227.         gethostbyname' reads 'gethostname', wheras the actual
  228.         'gethostname' page is the next one. This should be changed
  229.         to 'gethostbyname'.
  230.  
  231. Page 69:    Remarks section: "getservbyport() returns a pointer to a .."
  232.                                     ^^^
  233.         Word 'to' must be inserted.
  234.  
  235. Page 105:    Remarks section, 2nd para., 4th sentence currently reads
  236.         "If this version is higher than the lowest version supported
  237.         by the DLL". I beleive this should read "... higher or equal to
  238.         ...". Implementations using this literally may fail to
  239.         correctly register v1.1 applications when the DLL supports
  240.         versions v1.1 and higher (e.g. 2.0).
  241.  
  242.     
  243. Clarifications and minor additions
  244. ----------------------------------
  245.  
  246. Page 25/26: connect().
  247.         The BSD form of connect() allows multiple connect() functions
  248.         to be called for SOCK_DGRAM (And presumably SOCK_RAW)
  249.         sockets, to change the remote destination binding. Also,
  250.         it allows connect()ing to an invalid address (usually
  251.         all zeros) to mean 'disconnect' the socket, and start 
  252.         accepting datagrams from all remote sources.
  253.  
  254.         For this functionality to be described by the Winsock Spec,
  255.         the following alterations need to be made:
  256.     
  257.         remarks section, 1st para, change last sentence to:
  258.         "..., connect() will return WSAEDDRNOTAVAIL for SOCK_STREAM
  259.         sockets. Datagram-based sockets (SOCK_DGRAM, SOCK_RAW)
  260.         will be 'disconnected', and start accepting datagrams from
  261.         multiple remote sources.
  262.  
  263.         Add new sentences to last paragraph about SOCK_DGRAM
  264.         sockets:
  265.         "Multiple connect() calls may be used to alter the default
  266.         remote destination, and a connect() call with a name containing
  267.         all zeros will return the socket to a 'dis-connected' state.    
  268.  
  269.         Error codes: Add (SOCK_STREAM only) to the explanation for
  270.         WSAEADDRNOTAVAIL and WSAEISCONN error codes.
  271.  
  272. P35, ioctlsocket().
  273.         The argp argument points to a 'u_long FAR *', and all commands
  274.         except SIOCATMARK specify their arguemnts to be real unsigned
  275.         long values. SIOCATMARK, however, states that 'argp' points
  276.         to a BOOL. Now a BOOL is defined as an int, which size
  277.         is different on different processor architectures, and it is
  278.         unclear whether this command should operate on a 16-bit
  279.         or 32-bit quantity - there exist implementations of DLLs
  280.         and applications that assume both - this confusion is very bad
  281.         for interoperability.
  282.  
  283.         I beleive the best solution is for ioctlsocket() to
  284.         always operate on 32-bit (or at least, 'u_long') quantities,
  285.         and that the last sentence on page 35 should read something
  286.         like: "argp points at an unsigned long, in which ioctlsocket()
  287.         stores the result: either FALSE (0) or TRUE (!0)."
  288.  
  289. P 48, send()
  290.         The description for send() seems to prohibit the harmless
  291.         practice of calling send() with a length of 0. A recent
  292.         poll conducted by myself came back 4:1 in favour of
  293.         send() allowing a length of 0, and in this case the valid
  294.         return code of 0 indicates 'all requested data sent' as 
  295.         expected. This seems to be common practice in many,
  296.         but not all implementations, anyway. I propose the
  297.         third paragraph in the Remarks section add some text to
  298.         legitimise this practice.
  299.  
  300.  
  301.  
  302. -- 
  303. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard:
  304. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet
  305. 579 Harris St., Ultimo   |                         |  been superseded.
  306. Sydney Australia 2007    |ph: +61 2 281 3155       |  
  307. From David_B_Andersen@ccm.jf.intel.com Mon Apr 11 10:06:49 1994
  308. Received: from ormail.intel.com by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  309.           id AA24399; Mon, 11 Apr 1994 21:06:53 -0400
  310. Received: from ccm.hf.intel.com by ormail.intel.com
  311.     (Smail3.1.28.1 #2) id m0pqWwD-000MNbC; Mon, 11 Apr 94 18:06 PDT
  312. Received: by ccm.hf.intel.com (ccmgate 3.0) Mon, 11 Apr 94 18:06:49 PST
  313. Date: Mon, 11 Apr 94 18:06:49 PST
  314. From: David B Andersen <David_B_Andersen@ccm.jf.intel.com>
  315. Message-Id: <940411180649_1@ccm.hf.intel.com>
  316. To: winsock-hackers@SunSITE.Unc.EDU
  317. Subject: Re: WSAENOBUFS error from WSAAsyncGetXXXByYYY
  318.  
  319.      IMHO, the correct behaviour is to return the async task handle (what a 
  320.      misnomer!) and then post a message with the WSAENOBUFS error code.  My 
  321.      reasons for believing this is that WSAENOBUFS is *not* one of the 
  322.      defined error codes for the situation when the asynchronous operation 
  323.      could not be (or simply was not) launched.
  324.      
  325.      --Dave B. Andersen
  326.        Intel Architecture Labs
  327.  
  328.  
  329. ______________________________ Reply Separator _________________________________
  330. Subject: WSAENOBUFS error from WSAAsyncGetXXXByYYY
  331. Author:  winsock-hackers@SunSITE.Unc.EDU at Internet_Gateway
  332. Date:    4/9/94 1:21 AM
  333.  
  334.  
  335. I've got a problem with my stack testing, and would like to 
  336. take another straw poll (results of the last one soon!)
  337.      
  338. The application is expecting all error returns from WSAAsyncGetXXXByYYY 
  339. routines to be returned along with the completion message.
  340. Some conditions, however, are detectable at the time the call is made.
  341. The one causing the trouble at the moment is WSAENOBUFS. If the application 
  342. calls WSAAsynGetHostByName with buf==NULL, I fail the call immediately, 
  343. instead of accepting the call then immediately posting a message with 
  344. WSAENOBUFS in LPARAM. Now failing the call immediately seems to be perfectly 
  345. valid from my reading of the spec - what do you all do/say/expect?
  346.      
  347.      
  348. --
  349. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard: 
  350. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet 
  351. 579 Harris St., Ultimo   |                         |  been superseded. 
  352. Sydney Australia 2007    |ph: +61 2 281 3155       |
  353. From paul@atlas.dev.abccomp.oz.au Wed Apr 13 04:08:23 1994
  354. Received: from usage.csd.unsw.OZ.AU by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  355.           id AA15014; Tue, 12 Apr 1994 18:55:19 -0400
  356. Received: by usage.csd.unsw.OZ.AU id AA25725
  357.   (5.65c/IDA-1.4.4 for winsock-hackers%sunsite.unc.edu); Wed, 13 Apr 1994 08:55:16 +1000
  358. Received: by atlas (4.1/1.35)
  359.     id AA03728; Wed, 13 Apr 94 09:08:24 EST
  360. Message-Id: <9404122308.AA03728@atlas>
  361. From: paul@atlas.abccomp.oz.au
  362. Date: Wed, 13 Apr 1994 09:08:23 -0500
  363. X-Mailer: Mail User's Shell (7.2.2 4/12/91)
  364. To: winsock-hackers@sunsite.unc.edu
  365. Subject: WSAAsyncGetXXXbyYYY returns revisited
  366.  
  367. Recently I posted asking for opinions on failing WSAAsyncGetXXXbyYYY calls
  368. immediately, if the implementation could decide then the call would not
  369. succeed, i.e. if the buffer parameter was NULL.
  370.     While I had a couple of messages indictaing it seemed a fair thing
  371. to do, Scott Robins reminded me:
  372.  
  373. Thus expounded Question Reality  11-Apr-1994 0956 -0400 on Apr 11, 9:56am:
  374. /--------------------
  375. |
  376. |I think that failing it immediately would be a reasonable action.  However,
  377. |I just don't think that the spec reads that way.  And since V1.1 is already
  378. |out there, I don't see a need to change this behaviour.
  379.  
  380.  
  381. ...and after reading the spec again carefully, I realise I was
  382. mis-interpreting the text, and that it is reasonably explicit in saying
  383. that only if the call could not be initiated or queued for some reason
  384. should the initial call fail.
  385.     I agree with Scott here - it might be a reasonable thing to do,
  386. but it isn't compliant with the published spec. - so I'll be
  387. changing our stack.
  388.  
  389. Thanks all.
  390.  
  391.  
  392. -- 
  393. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard:
  394. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet
  395. 579 Harris St., Ultimo   |                         |  been superseded.
  396. Sydney Australia 2007    |ph: +61 2 281 3155       |  
  397. From dudley@hosv1.att.com Wed Apr 16 02:02:00 1994
  398. Received: from gw1.att.com by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  399.           id AA07149; Fri, 15 Apr 1994 22:02:47 -0400
  400. To: winsock-hackers@SunSITE.Unc.EDU
  401. Received: from hosv1.UUCP by ig1.att.att.com id AA29976; Fri, 15 Apr 94 22:02:51 EDT
  402. Message-Id: <9404160202.AA29976@ig1.att.att.com>
  403. From: dudley@hosv1.att.com
  404. Date: 16 Apr 94 02:02:00 GMT
  405. Apparently-To: winsock-hackers@SunSITE.Unc.EDU
  406.  
  407. I will be away from the office from April 18, 1994
  408. until April 25,1994.  I will pick up e-mail messages
  409. on or about April 25, if you have a question or concern
  410. that can not wait until that time, please call x-3800 for
  411. system related problems or concerns or x-4464 for plotter
  412. releated problems or concerns.
  413.  
  414. Dudley
  415. From paul@atlas.dev.abccomp.oz.au Mon Apr 18 05:37:47 1994
  416. Received: from usage.csd.unsw.OZ.AU by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  417.           id AA29318; Sun, 17 Apr 1994 20:24:25 -0400
  418. Received: by usage.csd.unsw.OZ.AU id AA24894
  419.   (5.65c/IDA-1.4.4 for winsock-hackers%sunsite.unc.edu); Mon, 18 Apr 1994 10:24:32 +1000
  420. Received: by atlas (4.1/1.35)
  421.     id AA05577; Mon, 18 Apr 94 10:37:48 EST
  422. Message-Id: <9404180037.AA05577@atlas>
  423. From: paul@atlas.abccomp.oz.au
  424. Date: Mon, 18 Apr 1994 10:37:47 -0500
  425. X-Mailer: Mail User's Shell (7.2.2 4/12/91)
  426. To: rcq@ftp.com, Multiple recipients of list <winsock-hackers@sunsite.unc.edu>
  427. Subject: Re: setoptsock()
  428.  
  429. Thus expounded Bob Quinn on Apr 15,10:01pm:
  430. /--------------------
  431. |>  setoptsock() allows socket programmers to modify the socket
  432. |>  options, like the buffer size for sending and receiving.(using 
  433. |>  level= SOL_SOCKET and optname= SO_RCVBUF and SO_SNDBUF)
  434. |>  
  435. |>  My question is when the  _receiving_  buffer size is bigger than one UDP packet,
  436. |>  say 5 times. Will the incoming 5 packets be held in the buffer if
  437. |>  the app doesn't read it ? Or no matter how big the buffer size is,
  438. |>  it always holds just one UDP packet and discard the subsequence UDP
  439. |>  packets if the apps doesn't read it ? What about if the buffer size
  440. |>  is 5.3 times of the size of the incoming UDP packets , would the 
  441. |>  6th one be stuffed into the remaining buffer size -- .3 of the UDP
  442. |>  packet ?
  443. |
  444. |The spec is clear: "if the datagram is larger than the buffer
  445. |supplied, the buffer is filled with the first part of the
  446. |datagram, the excess data is lost, and recv() returns the
  447. |error WSAEMSGSIZE."  Where's the ambiguity?  Basically, if
  448. |you snooze, you lose :)
  449.  
  450. Bzzt: sorry Bob, I think you are talking about the wrong buffer.
  451. I beleive that passage you quoted refers to the buffer provided by the
  452. caller in the recv() call - if the LEN parameter is only, say,
  453. 1K, and the queued datagram is, say, 2K, thn you only get the first
  454. 1K of the queued datagram, as you said.
  455.     The question, on the other hand, was about the internal socket
  456. buffer for all the queued datagrams - the one affected by the SO_RCVBUF
  457. socket option. This is a different kettle of fish.
  458.  
  459. |I admit, we violate the spec in this regard.  But I contend 
  460. |that we are justified in doing so because the lack of an 
  461. |asymmetrical send/recv iMaxUdpDg represents a deficiency in 
  462. |the specification.
  463. |
  464. |Comments?
  465.  
  466. Given that fragmentation of outgoing datagrams is simple, all the way up to
  467. the full 64K size of a maximum IP datagram, I don't believe any implementation
  468. _will_ have a need for a separate limit on the size of outgoing UDP datagrams,
  469. and that the iMaxUdpDg parameter relates to the maximum size the implementation
  470. is prepared to re-assemble from incoming fragments. Otherwise you get people
  471. setting up 'black holes' when they set things up to use the same
  472. maximum-size UDP datagrams out and in. If you have a separate size of 
  473. maximum outgoing and maximum incoming datagrams, the iMaxUdpDg parameter
  474. should be set to the lower of these, to warn the poor application that
  475. the underlying stack may be insufficient for its requirements.
  476.  
  477.  
  478. -- 
  479. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard:
  480. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet
  481. 579 Harris St., Ultimo   |                         |  been superseded.
  482. Sydney Australia 2007    |ph: +61 2 281 3155       |  
  483. From paul@atlas.dev.abccomp.oz.au Mon Apr 18 05:48:32 1994
  484. Received: from usage.csd.unsw.OZ.AU by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  485.           id AA00619; Sun, 17 Apr 1994 20:35:59 -0400
  486. Received: by usage.csd.unsw.OZ.AU id AA25378
  487.   (5.65c/IDA-1.4.4 for winsock-hackers%sunsite.unc.edu); Mon, 18 Apr 1994 10:35:15 +1000
  488. Received: by atlas (4.1/1.35)
  489.     id AA05611; Mon, 18 Apr 94 10:48:32 EST
  490. Message-Id: <9404180048.AA05611@atlas>
  491. From: paul@atlas.abccomp.oz.au
  492. Date: Mon, 18 Apr 1994 10:48:32 -0500
  493. X-Mailer: Mail User's Shell (7.2.2 4/12/91)
  494. To: rcq@ftp.com, Multiple recipients of list <winsock-hackers@sunsite.unc.edu>
  495. Subject: Re: closesocket()/WSACleanup() question
  496.  
  497. Thus expounded Bob Quinn on Apr 15,10:26pm:
  498. /--------------------
  499. |One of our customers recently brought a statement in the documen-
  500. |tation for WSACleanup() to my attention.  I am amazed that the
  501. |section he quoted made it into the specification at all, let alone
  502. |the fact it's never been questioned since.  Here is the customer's
  503. |message text (forwarded with his permission):
  504. |
  505. |>  I see this as a bug in the implementation.  There shouldn't 
  506. |>  be any need to wait for the TCP close to complete before the 
  507. |>  call to WSACleanup().  Winsock spec 1.1 said
  508. |>  
  509. |>       "Any open SOCK_STREAM sockets that are connected when
  510. |>  WSACleanup() is called are reset; sockets which have been closed 
  511. |>  with closesocket() but which still have pending data to be sent 
  512. |>  are not affected--the pending data is still sent."
  513. |>  
  514. |>  As you see, it explicitly said that in the last statement.  This 
  515. |>  is also comfirm by the same behavior in other TCP/IP vendors such 
  516. |>  as Lan Workplace, BW, and NetManage.
  517. |
  518. |This requirement is inappropriate for a few reasons:
  519.  
  520. [etc]
  521.  
  522. My thoughts are that these requirements can be met, _PROVIDED_ this is not
  523. the last app. to call WSACleanup() - in this case, the DLL stays in memory
  524. and can manage the data. The requirements are still met by specific
  525. implementations - ours, where a DOS TSR manages the sending of data,
  526. independently of the presence or absence of a DLL, and probably a similar
  527. case if a VxD is used.
  528.     Bob is correct, though - those requirements are not appropriate in 
  529. general, and cannot be guaranteed by a pure DLL implementation of Windows
  530. Sockets, because the DLL will have to chuck the data when it unloads. I guess
  531. they might be beleiving an application will call WSACleanup(), then hang
  532. araound for a while doing other things, or something.
  533.  
  534. I agree, Bob, - there is no way to guarantee in all cases that data pending
  535. to be sent on a closed socket will still be sent after WSACleanup() is
  536. called, no matter what the spec. says.
  537.  
  538.  
  539. -- 
  540. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard:
  541. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet
  542. 579 Harris St., Ultimo   |                         |  been superseded.
  543. Sydney Australia 2007    |ph: +61 2 281 3155       |  
  544. From roger.kries@crpht.lu Mon Apr 18 13:55:56 1994
  545. Received: from arthur.crpht.lu by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  546.           id AA20414; Mon, 18 Apr 1994 06:56:45 -0400
  547. Message-Id: <199404181056.AA20414@SunSITE.Unc.EDU>
  548. Received: from buster.crpht.lu by arthur.crpht.lu with SMTP
  549.     (1.37.109.4/16.2) id AA18472; Mon, 18 Apr 94 12:57:05 +0200
  550. X-Sender: kries@arthur.crpht.lu
  551. Mime-Version: 1.0
  552. Content-Type: text/plain; charset="us-ascii"
  553. Date: Mon, 18 Apr 1994 12:55:56 +0100
  554. To: winsock-hackers@sunsite.unc.edu
  555. From: roger.kries@crpht.lu (Roger Kries)
  556. Subject: Q: How to connect with a timeout ?
  557.  
  558. I'm having some problems writing Berkley Sockets API compatible code to
  559. connect to a machine with a timeout value. That's to say, I want to
  560. connect to a machine, but if I cannot connect until the timeout is
  561. elapsed I give up.
  562.  
  563. My solution was to call connect() on a non-blocking socket and then to
  564. call select() with the timeout value and to check if the socket is
  565. writeable.
  566.  
  567. This method is described in the Winsock specification at page 25:
  568. > On a non-blocking socket, if the return value is SOCKET_ERROR an
  569. > application should call WSAGetLastError(). If this indicates an error
  570. > code of WSAEWOULDBLOCK, then your application can either:
  571. > 1. Use select() to determine the completion of the connection by
  572. > checking if the socket is writeable, or
  573. > 2. ...
  574. The second method is not Berkley Sockets compatible.
  575.  
  576. All this seems to be very fine, but after testing the method on
  577. a PC with Trumpet Winsock.dll, on a macintosh with a special socket
  578. library (GUSI) and on a HP-UX machine, the following problem arises:
  579.  
  580.  If at the moment of the connect call, the remote machine has no socket
  581.  created that listens to the specified port, the following select() call
  582.  will always timeout, even if during the timeout interval a program is
  583.  started that listens to the port. That means that in the case where a
  584.  blocking connect call would return ECONNREFUSED, a non-blocking returns
  585.  WSAWOULDBLOCK, but the select call always timeouts.
  586.  
  587. So how can I find out if the remote machine is listening to a specific
  588. TCP port without blocking and in a Berkley Socket compatible manner?
  589.  
  590. Any suggestions are welcome. Thanx in advance.
  591.